{extend name="public/base" /}
{block name="title"}
<h1>编辑后台菜单</h1>
{/block}
{block name="content"}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-header">
                </div>
                <form class="form-horizontal" action="{:url('menu/adminMenuEdit')}" method="post" id="subForm">
                    {:token()}
                    <input type="hidden" id="menu_parent_id" name="menu_parent_id" value="{$model.menu_parent_id}">
                    <input type="hidden" id="menu_depth" name="menu_depth" value="{$model.menu_depth}">
                    <input type="hidden" id="id" name="id" value="{$model.menu_id}">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="menu_parent_name" class="col-sm-3 control-label">上级菜单</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="menu_parent_name" name="menu_parent_name" readonly="readonly"
                                       value="{$model.menu_parent_name}" placeholder="上级菜单">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu_name" class="col-sm-3 control-label"><span
                                    class="text-danger">* </span>菜单名称</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="menu_name" name="menu_name"
                                       value="{$model.menu_name}" placeholder="菜单名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu_page_url" class="col-sm-3 control-label"><span
                                    class="text-danger">* </span>跳转路径</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="menu_page_url" name="menu_page_url"
                                       value="{$model.menu_page_url}" placeholder="跳转路径">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu_icon" class="col-sm-3 control-label">菜单图标</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="menu_icon" name="menu_icon"
                                       value="{$model.menu_icon}" placeholder="菜单图标">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="menu_sort" class="col-sm-3 control-label">排序(数字越小越靠前)</label>
                            <div class="col-sm-4">
                                <input type="number" class="form-control" id="menu_sort" name="menu_sort"
                                       value="{$model.menu_sort}" placeholder="排序">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 col-md-offset-3 checkbox">
                                <label>
                                    <input type="checkbox" name="menu_status" id="menu_status" value="1" {if $model.menu_status==1}checked{/if}>
                                    是否显示
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="box-footer">
                        <a href="javascript:" class="btn btn-default" onclick="doGoBack()">
                            <i class="fa fa-arrow-left"></i>返回
                        </a>
                        <button type="submit" class="btn btn-primary col-md-offset-3">
                            <i class="fa fa-save"></i>保存
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
{/block}
{block name="script"}
{load href="/static/common/js/validate/jquery.validate.min.js"}
{load href="/static/common/js/validate/messages_zh.min.js"}
{load href="/static/common/js/validate/base.validate.js"}
<script type="text/javascript">
    var doGoBack = function () {
        window.location = "{:url('menu/adminmenuindex')}";
    };
    $(function () {
        var e = "<i class='fa fa-times-circle'></i>";
        $("#subForm").validate({
            rules: {
                menu_name: {
                    required: true,
                    maxlength: 20
                },
                menu_page_url: {
                    required: true,
                    maxlength: 50
                },
                menu_icon: {
                    maxlength: 20
                },
                menu_sort: {
                    required: true,
                    range: [0, 999]
                }
            },
            messages: {
                menu_name: {
                    required: e + "请输入菜单名称",
                    maxlength: e + "菜单名称长度不能超过20个字符"
                },
                menu_page_url: {
                    required: e + "请输入跳转链接",
                    maxlength: e + "跳转链接长度不能超过50个字符"
                },
                menu_icon: {
                    maxlength: e + "菜单图标长度不能超过20个字符"
                },
                menu_sort: {
                    required: e + "请输入排序",
                    range: e + "排序范围在0到999之间"
                }
            }
        });
    });
</script>
{/block}